<template>
  <div class="home-entrance-container">
    <!-- 顶部标题 -->
    <div class="entrance-header">
      <h3 class="header-title">快捷入口</h3>
      <div class="divider"></div>
    </div>
    
    <!-- 宫格入口 -->
    <van-grid :column-num="4" :gutter="10" class="custom-grid">
      <van-grid-item 
        v-for="(item, index) in homeItems" 
        :key="index"
        :to="{ name: item.routeName }"
        class="grid-item"
      >
        <div class="grid-icon-container">
          <img :src="item.img" alt="" class="grid-icon">
        </div>
        <div class="grid-text">{{ item.title }}</div>
      </van-grid-item>
    </van-grid>
  </div>
</template>

<script>
import menu1 from "@/assets/images/menu1.png";
import menu2 from "@/assets/images/menu2.png";
import menu3 from "@/assets/images/menu3.png";
import menu4 from "@/assets/images/menu4.png";
import menu5 from "@/assets/images/menu5.png";
import menu6 from "@/assets/images/menu6.png";
import menu7 from "@/assets/images/menu7.png";
import menu8 from "@/assets/images/menu8.png";
import menu9 from "@/assets/images/menu9.png";
import menu10 from "@/assets/images/menu10.png";
import menu11 from "@/assets/images/menu11.png";
import menu12 from "@/assets/images/menu12.png";

export default {
  name: 'homeEnter',
  data() {
    return {
      // 首页快捷功能入口
      homeItems: [
        { title: "美食", routeName: "verticalTabs", img: menu5 },
        { title: "团购", img: menu6 },
        { title: "生鲜果蔬", img: menu7 },
        { title: "下午茶", img: menu8 },
        { title: "正餐优选", routeName: "dinnerList", img: menu9 },
        { title: "休闲玩乐",img: menu10 },
        { title: "丽人美发", img: menu11 },
        { title: "电影演出",img: menu12 },
        { title: "我的订单", routeName: "orderList", img: menu1 },
        { title: "我的收藏", routeName: "myFavorites", img: menu2 },
        { title: "留言反馈", routeName: "feedback", img: menu3 },
        { title: "联系我们", routeName: "contact-us", img: menu4 },
      ],
    };
  },
  mounted() {
    // 添加进入动画
    this.$nextTick(() => {
      const items = document.querySelectorAll('.grid-item');
      items.forEach((item, index) => {
        setTimeout(() => {
          item.classList.add('animate-in');
        }, 100 * index);
      });
    });
  },
};
</script>

<style scoped>
.home-entrance-container {
  padding: 16px;
  background-color: white;
  border-radius: 12px;
  margin: 16px 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.custom-grid {
  padding: 8px;
}

.grid-item {
  position: relative;
  background-color: transparent;
  transition: all 0.3s ease;
  transform: translateY(10px);
}

.grid-item.animate-in {
  opacity: 1;
  transform: translateY(0);
}

.grid-item::after {
  display: none; /* 移除Vant默认的边框 */
}

.grid-item:hover {
  transform: translateY(-5px);
}

.grid-icon-container {
  width: 50px;
  height: 50px;
  margin: 0 auto 8px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  background-color: white;
  overflow: hidden;
}

.grid-icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
  transition: transform 0.3s ease;
}

.grid-item:hover .grid-icon {
  transform: scale(1.1);
}

.grid-text {
  font-size: 14px;
  color: #666;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

</style>
